import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 使用query string进行前后端交互
 */

//请求格式（query string）：username=Hikari&password=123

@WebServlet("/getParameter")
public class GetParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        //query string会被解析成Map，getParameter()就是与key匹配，匹配到了，赋成val
        String username = req.getParameter("username");
        String password = req.getParameter("password");

        System.out.println("username=" + username);
        System.out.println("password=" + password);

        resp.getWriter().write("ok");
    }
}
